
#include "mainwindow.h"
#include "./ui_mainwindow.h"

#include "GameModel.h"
#include "QPainter"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //设置窗口大小
    setFixedSize(margin * 2 + block_size * board_size,
                 margin * 2 + block_size * board_size);

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    //绘制棋盘
    painter.setRenderHint(QPainter::Antialiasing,true);//抗锯齿
    for(int i=0;i<board_size+1;i++){
        //竖线
        painter.drawLine(margin+block_size*i,margin,
                         margin+block_size*i,size().height()-margin);
        //横线
        painter.drawLine(margin,margin+block_size*i,
                         size().width()-margin,margin+block_size*i);
    }
}
